﻿using System;
using XmlVisualizer.Models;
using XmlVisualizer.Views;

namespace XmlVisualizer.Controllers
{
    /// <summary>
    /// Controller responsible for handling user actions from the view
    /// and passing those actions to the model.
    /// </summary>
    public class XmlController : IController
    {
        private XmlModel xmlModel; // reference to the model 
        private IView xmlView; // reference to the UI

        /// <summary>
        /// XmlController constructor, sets model and view, registers view as 
        /// an observer
        /// </summary>
        /// <param name="model">reference to the model</param>
        /// <param name="view">reference to the view</param>
        public XmlController(ref XmlModel model, ref IView view)
        {
            xmlModel = model;
            xmlView = view;
            model.RegisterObserver((Observer)view);
        }

        #region IController Members

        public void View_NewFile()
        {
            throw new NotImplementedException();
        }

        public void View_OpenFile(string filename)
        {
            throw new NotImplementedException();
        }

        public void View_SaveFile(string filename)
        {
            throw new NotImplementedException();
        }

        public void View_Undo()
        {
            throw new NotImplementedException();
        }

        public void View_Redo()
        {
            throw new NotImplementedException();
        }

        public void View_Settings()
        {
            throw new NotImplementedException();
        }

        public void View_Exit()
        {
            throw new NotImplementedException();
        }

        #endregion
    };

    public class XsdController : IController
    {
        private XsdModel xsdModel; // reference to the model 
        private IView xmlView; // reference to the UI

        /// <summary>
        /// XsdController constructor, sets model and view, registers view as 
        /// an observer
        /// </summary>
        /// <param name="model">reference to the model</param>
        /// <param name="view">reference to the view</param>
        public XsdController(ref XsdModel model, ref IView view)
        {
            xsdModel = model;
            xmlView = view;
            model.RegisterObserver((Observer)view);
        }

        #region IController Members

        public void View_NewFile()
        {
            throw new NotImplementedException();
        }

        public void View_OpenFile(string filename)
        {
            throw new NotImplementedException();
        }

        public void View_SaveFile(string filename)
        {
            throw new NotImplementedException();
        }

        public void View_Undo()
        {
            throw new NotImplementedException();
        }

        public void View_Redo()
        {
            throw new NotImplementedException();
        }

        public void View_Settings()
        {
            throw new NotImplementedException();
        }

        public void View_Exit()
        {
            throw new NotImplementedException();
        }

        #endregion
    };

    /// <summary>
    /// Application controller controls applications tasks, mostly
    /// ...to do: add
    /// </summary>
    public class ApplicationController : IController
    {
        private ApplicationModel applicationModel;
        private IView applicationView;

        public IView View
        {
            get { return applicationView; }
        }

        public ApplicationModel Model
        {
            get { return applicationModel; }
        }

        /// <summary>
        /// ApllicationController's constructor, sets the applicationModel
        /// and applicationView
        /// </summary>
        /// <param name="appModel">reference to the ApplicationModel</param>
        /// <param name="appView">reference to the IView</param>
        public ApplicationController(ref ApplicationModel appModel, ref IView appView)
        {
            applicationModel = appModel;
            applicationView = appView;
        }

        public virtual void View_NewFile()
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Opens file with name filename
        /// </summary>
        /// <param name="filename">file to open</param>
        public virtual void View_OpenFile(String filename)
        {
            applicationModel.OpenFile(filename);
        }

        public virtual void View_SaveFile(String filename)
        {
            throw new NotImplementedException();
        }

        public virtual void View_Undo()
        {
            throw new NotImplementedException();
        }

        public virtual void View_Redo()
        {
            throw new NotImplementedException();
        }

        public virtual void View_Settings()
        {
            throw new NotImplementedException();
        }

        public virtual void View_Exit()
        {
            throw new NotImplementedException();
        }
    };
};